﻿/*
 * @(#)AppLogger.cs, 2010-5-19 17:03:56.
 *
 * @author fengxianwen.
 *
 *
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using SFWS.XJSON.Core;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace JKF.Substructure
{
    /// <summary>
    /// 应用程序记录日志工具。
    /// </summary>
    public static class AppLogger
    {
        /// <summary>
        /// 记录违例信息。
        /// </summary>
        public static void Log(string title, Exception ex)
        {
            log(title + "[EXCEPTION]", string.Format("{0}", ex), TraceEventType.Error);
        }

        /// <summary>
        /// 记录一般信息。
        /// </summary>
        public static void Log(string title, string message)
        {
            log(title, message, TraceEventType.Information);
        }

        /// <summary>
        /// 记录一般信息。
        /// </summary>
        private static void log(string title, string message, TraceEventType severity)
        {
            try
            {
                LogEntry l = new LogEntry();
                l.Title = title;
                l.Message = message;
                l.Severity = severity;
                //l.TimeStamp = DB.HR.GetNow();

                Logger.Write(l);
            }
            catch
            {
            }
        }

    }
}
